import React from 'react'
import { TransitionGroup, CSSTransition } from 'react-transition-group'
import { Switch, Route } from 'react-router-dom'
// import './AnimatedSwitch.scss'


const AnimatedSwitch = props => {
    const { children } = props
    return (
        <Route render={({ location }) => (
            <TransitionGroup>
                <CSSTransition
                    key={location.key}
                    classNames={props.type || 'fade'}
                    timeout={props.duration || 800}
                >
                    <Switch location={location}>{children}</Switch>
                </CSSTransition>
            </TransitionGroup>
        )}
        />
    )
}
export default AnimatedSwitch 
